import { CreateLLMProviderRequest, LLMProvider, ListLLMProviderRequest, ListLLMProviderResponse, DeleteLLMProviderRequest, UpdateLLMProviderRequest, GetLLMAssistantRequest, AssistantTestRequest} from "@/types/proto/api/v1/llm_service";
import { CreateLLMModelRequest, LLMModel, ListLLMModelRequest, ListLLMModelResponse, DeleteLLMModelRequest, UpdateLLMModelRequest} from "@/types/proto/api/v1/llm_service";
import { CreateLLMAssistantRequest, LLMAssistant, ListLLMAssistantRequest, ListLLMAssistantResponse, DeleteLLMAssistantRequest, UpdateLLMAssistantRequest} from "@/types/proto/api/v1/llm_service";

import { GeneratePromptRequest, GeneratePromptResponse, ListLLMProviderSpecRequest,AssistantTestResponse, ListLLMProviderSpecResponse} from "@/types/proto/api/v1/llm_service";

import { llmServiceClient} from "./grpcweb_auth";
import { Empty } from "@/types/proto/google/protobuf/empty";

export async function CreateProvider(data: CreateLLMProviderRequest): Promise<LLMProvider> {
    try {
      return llmServiceClient.createLLMProvider(data)
    } catch (error) {
      console.error('gRPC request failed:', error);
      throw error;
    }
}

export async function ListProviders(data: ListLLMProviderRequest): Promise<ListLLMProviderResponse> {
    try {
      return llmServiceClient.listLLMProviders(data)
    } catch (error) {
      console.error('gRPC request failed:', error);
      throw error;
    }
}

export async function UpdateProvider(data: UpdateLLMProviderRequest): Promise<LLMProvider> {
    try {
      return llmServiceClient.updateLLMProvider(data)
    } catch (error) {
      console.error('gRPC request failed:', error);
      throw error;
    }
}

export async function DeleteProvider(data: DeleteLLMProviderRequest): Promise<Empty> {
    try {
      return llmServiceClient.deleteLLMProvider(data)
    } catch (error) {
      console.error('gRPC request failed:', error);
      throw error;
    }
}

export async function CreateModel(data: CreateLLMModelRequest): Promise<LLMModel> {
    try {
      return llmServiceClient.createLLMModel(data)
    } catch (error) {
      console.error('gRPC request failed:', error);
      throw error;
    }
}

export async function ListModels(data: ListLLMModelRequest): Promise<ListLLMModelResponse> {
    try {
      return llmServiceClient.listLLMModels(data)
    } catch (error) {
      console.error('gRPC request failed:', error);
      throw error;
    }
}

export async function UpdateModel(data: UpdateLLMModelRequest): Promise<LLMModel> {
    try {
      return llmServiceClient.updateLLMModel(data)
    } catch (error) {
      console.error('gRPC request failed:', error);
      throw error;
    }
}

export async function DeleteModel(data: DeleteLLMModelRequest): Promise<Empty> {
    try {
      return llmServiceClient.deleteLLMModel(data)
    } catch (error) {
      console.error('gRPC request failed:', error);
      throw error;
    }
}

export async function CreateAssistant(data: CreateLLMAssistantRequest): Promise<LLMAssistant> {
    try {
      return llmServiceClient.createLLMAssistant(data)
    } catch (error) {
      console.error('gRPC request failed:', error);
      throw error;
    }
}

export async function ListAssistants(data: ListLLMAssistantRequest): Promise<ListLLMAssistantResponse> {
    try {
      return llmServiceClient.listLLMAssistants(data)
    } catch (error) {
      console.error('gRPC request failed:', error);
      throw error;
    }
}

export async function UpdateAssistant(data: UpdateLLMAssistantRequest): Promise<LLMAssistant> {
    try {
      return llmServiceClient.updateLLMAssistant(data)
    } catch (error) {
      console.error('gRPC request failed:', error);
      throw error;
    }
}

export async function DeleteAssistant(data: DeleteLLMAssistantRequest): Promise<Empty> {
    try {
      return llmServiceClient.deleteLLMAssistant(data)
    } catch (error) {
      console.error('gRPC request failed:', error);
      throw error;
    }
}

export async function GeneratePrompt(data: GeneratePromptRequest): Promise<GeneratePromptResponse> {
    try {
      return llmServiceClient.generatePrompt(data)
    } catch (error) {
      console.error('gRPC request failed:', error);
      throw error;
    }
}

export async function ListProviderSpec(data: ListLLMProviderSpecRequest): Promise<ListLLMProviderSpecResponse> {
  try {
    return llmServiceClient.listLLMProviderSpecs(data)
  } catch (error) {
    console.error('gRPC request failed:', error);
    throw error;
  }
}


export async function GetAssistant(data: GetLLMAssistantRequest): Promise<LLMAssistant> {
  try {
    return llmServiceClient.getLLMAssistant(data)
  } catch (error) {
    console.error('gRPC request failed:', error);
    throw error;
  }
}

export async function AssistantTest(data: AssistantTestRequest): Promise<AssistantTestResponse> {
  try {
    return llmServiceClient.assistantTest(data)
  } catch (error) {
    console.error('gRPC request failed:', error);
    throw error;
  }
}